package com.lagou;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class RedisCluster {

    public static void main(String[] args) {
        optRedis();
    }

    static void optRedis() {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<>();
        jedisClusterNode.add(new HostAndPort("192.168.80.122", 8001));
        jedisClusterNode.add(new HostAndPort("192.168.80.122", 8002));
        jedisClusterNode.add(new HostAndPort("192.168.80.122", 8003));
        jedisClusterNode.add(new HostAndPort("192.168.80.122", 8004));
        jedisClusterNode.add(new HostAndPort("192.168.80.122", 8005));
        jedisClusterNode.add(new HostAndPort("192.168.80.122", 8006));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        // jcd.set("name:1","java");

        String value = jcd.get("name:2");
        System.out.println(value);
    }
}
